package duotai;
class Animal {
	String name;
	int age;

	public Animal(String name, int age) {
		this.name = name;
		this.age = age;
	}

	public void eat () {
		System.out.println(name +"正在吃饭");
	}
}
class Dog extends Animal {
	String name;
	int age;

	public Dog(String name, int age) {
		super(name,age);
		this.name = name;
		this.age = age;
	}

	@Override
	public void eat() {
		System.out.println(name+"正在吃饭");
	}
	public  void swim () {
		System.out.println(name +"正在游泳");
	}
}
class Bird extends Animal {
	String name;
	int age;

	public Bird(String name, int age) {
		super(name, age);
		this.name = name;
		this.age = age;
	}
	public  void fly() {
		System.out.println(name +"正在飞");
	}
}
public class test2 {
	public static void main(String[] args) {
		Dog dog=new Dog("小黄",10);
		Animal animal1=new Bird("小环",12);
		//animal1.fly();//向下转型，不安全
		if(animal1 instanceof Bird) {
			Bird bird=(Bird) animal1;
			bird.fly();
		}else {
			System.out.println("不能飞");
		}
	}
}
